/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package visualization;

import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.layers.RenderableLayer;
import gov.nasa.worldwind.render.DrawContext;
import gov.nasa.worldwind.render.Polygon;
import gov.nasa.worldwind.render.Polyline;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Lukas
 */
public class BeamsLayer extends RenderableLayer
{
    private GroundData gData;
    private Ship ship;

    public BeamsLayer(GroundData gData, Ship ship)
    {
        this.gData = gData;
        this.ship = ship;
    }

    public void render(DrawContext dc)
    {
        for (int j = 0; j < gData.beamsNumber; j++)
        {
            List<Position> positions = new ArrayList<Position>();
            Position pos1 = ship.getPosition();
            Position pos2 = gData.positions[gData.currentPing][j];

            positions.add(pos1);
            positions.add(pos2);

            Polyline poly = new Polyline(positions);
            poly.setLineWidth(2);
            try
            {
                poly.render(dc);
            }
            catch (Exception e)
            {
            }
        }
    }
}
